using System;
using FireStarter.Base;
using FireStarterModeller.BO;

namespace FireStarter.CodeGeneration.Generator
{
    public class ValueExpression : TemplateExpression
    {
        private readonly string _propertyName;

        public ValueExpression(string propertyName)
        {
            _propertyName = propertyName;
        }

        public string PropertyName
        {
            get { return _propertyName; }
        }

        protected override string GenerateOne(IModelStrategyMapper mapper, IModelElement modelElement)
        {
            object value = mapper.GetStrategy(modelElement.GetType()).GetValue(mapper, modelElement, _propertyName);
            return Convert.ToString(value);
        }
    }
}